package com.mpyy.service.sales;

import com.mpyy.dao.sales.SellCurrentAccountingDao;
import com.mpyy.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @version 1.0
 * @Descrioption SellCurrentAccountingServiceImpl
 * @Author QIAO
 * @Date 2022-02-28 11:20
 */
@Service(value = "sellCurrentAccountingServiceImpl")
public class SellCurrentAccountingServiceImpl implements SellCurrentAccountingServiceInter {

    @Autowired
    @Qualifier(value = "sellCurrentAccountingDao")
    private SellCurrentAccountingDao sellCurrentAccountingDao;

    /**
     * 查询销售退货查询的上部分表格数据
     * @return
     */
    @Override
    public SaleOrder searchMortgageDataSaleOrder() {
        SaleOrder s = sellCurrentAccountingDao.searchMortgageDataSaleOrder();
        return s;
    }

    /**
     * 查询商品退货的最早时间
     * @return
     */
    @Override
    public SaleReturn searchMortgageDataSaleReturn() {
        SaleReturn saleReturn = sellCurrentAccountingDao.searchMortgageDataSaleReturn();
        return saleReturn;
    }

    /**
     * 查询往来账务的上部分表格内的数据
     * @param currentAccountingCustomers
     * @return
     */
    @Override
    public List<CurrentAccountingCustomers> currentAccounting(CurrentAccountingCustomers currentAccountingCustomers) {
        List<CurrentAccountingCustomers> currentAccountingDatas=sellCurrentAccountingDao.currentAccounting(currentAccountingCustomers);
        return currentAccountingDatas;
    }

    /**
     * 单据的详细信息
     * @param saleOrderDescAndSaleReturn
     * @return
     */
    @Override
    public List<SaleOrderDescAndSaleReturn> detailsOfTheDocument(SaleOrderDescAndSaleReturn saleOrderDescAndSaleReturn) {
        List<SaleOrderDescAndSaleReturn> detailsOfTheDocuments = sellCurrentAccountingDao.detailsOfTheDocument(saleOrderDescAndSaleReturn);
        return detailsOfTheDocuments;
    }

    /**
     * 查询客户表的数据
     * @param customerInfo
     * @return
     */
    @Override
    public List<CustomerInfo> customerAllInfo(CustomerInfo customerInfo) {
        List<CustomerInfo> customerInfos = sellCurrentAccountingDao.customerAllInfo(customerInfo);
        return customerInfos;
    }

    /**
     * 根据销售单号删除销售订单信息
     * @param saleOrder
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.REPEATABLE_READ)
    @Override
    public int deleteSaleOrderAndDescInfo(SaleOrder saleOrder, SaleOrderDesc saleOrderDesc) {
        int saleOrderRows = sellCurrentAccountingDao.deleteSaleOrderInfo(saleOrder);
        int saleOrderDescRows=sellCurrentAccountingDao.deleteSaleOrderDescInfo(saleOrderDesc);
        return 1;
    }

    /**
     * 根据销售单号删除退货订单信息
     * @param saleReturn
     * @param saleReturnDesc
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.REPEATABLE_READ)
    @Override
    public int deleteSaleReturnAndDescInfo(SaleReturn saleReturn, SaleReturnDesc saleReturnDesc) {
        int saleReturnRows=sellCurrentAccountingDao.deleteSaleReturnInfo(saleReturn);
        int saleReturnDescRows=sellCurrentAccountingDao.deleteSaleReturnDescInfo(saleReturnDesc);
        return 1;
    }

    /**
     * 查询客户消费情况数据
     * @param saleOrderDesc
     * @return
     */
    @Override
    public List<SaleOrderDesc> customerConsumption(SaleOrderDesc saleOrderDesc) {
        List<SaleOrderDesc> saleOrderDescs = sellCurrentAccountingDao.customerConsumption(saleOrderDesc);
        return saleOrderDescs;
    }

    /**
     * 查询客户账务信息数据
     * @param customerAccountingInformation
     * @return
     */
    @Override
    public List<CustomerAccountingInformation> customerAccountInformate(CustomerAccountingInformation customerAccountingInformation) {
        List<CustomerAccountingInformation> customerAccountingInformations = sellCurrentAccountingDao.customerAccountInformate(customerAccountingInformation);
        return customerAccountingInformations;
    }
}
